<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24" v-show="tabIndex === 0">
          <a-col :xl="8" :lg="11" :md="12" :sm="24">
            <a-form-item label="制单日期">
              <j-date placeholder="请选择开始日期" class="query-group-cust" v-model="unCreated_startTime_begin"></j-date>
              <span class="query-group-split-cust"></span>
              <j-date placeholder="请选择结束日期" class="query-group-cust" v-model="unCreated_startTime_end"></j-date>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
                <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
                  <a-button type="primary" @click="searchQueryUnCreated" icon="search">查询</a-button>
                  <a-button type="primary" @click="searchResetUnCreated" icon="reload" style="margin-left: 8px">重置</a-button>
                </span>
          </a-col>
        </a-row>
        <a-row :gutter="24" v-show="tabIndex === 1">
          <a-col :xl="8" :lg="11" :md="12" :sm="24">
            <a-form-item label="制单日期">
              <j-date placeholder="请选择开始日期" class="query-group-cust" v-model="notGenerated_startTime_begin"></j-date>
              <span class="query-group-split-cust"></span>
              <j-date placeholder="请选择结束日期" class="query-group-cust" v-model="notGenerated_startTime_end"></j-date>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
                <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
                  <a-button type="primary" @click="searchQueryNotGenerated" icon="search">查询</a-button>
                  <a-button type="primary" @click="searchResetNotGenerated" icon="reload" style="margin-left: 8px">重置</a-button>
                </span>
          </a-col>
        </a-row>
        <a-row :gutter="24" v-show="tabIndex === 4">
          <a-col :xl="8" :lg="11" :md="12" :sm="24">
            <a-form-item label="制单日期">
              <j-date placeholder="请选择开始日期" class="query-group-cust" v-model="startTime_begin"></j-date>
              <span class="query-group-split-cust"></span>
              <j-date placeholder="请选择结束日期" class="query-group-cust" v-model="startTime_end"></j-date>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
                <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
                  <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                  <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
                </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button v-show="tabIndex === 0" @click="handleAdd" type="primary" icon="plus">添加</a-button>
      <a-button v-show="tabIndex !== 0" type="primary" icon="download" @click="handlePlanExportXls('采购计划单')">导出</a-button>
      <a-button v-show="tabIndex === 4" @click="handleOpen" type="primary" icon="check">开启</a-button>
      <a-button v-show="tabIndex === 4" @click="handleClose" type="primary" icon="close">关闭</a-button>
      <a-button v-show="tabIndex === 0" @click="reviewView" type="primary" icon="unordered-list">设备请购单查看</a-button>
      <a-button v-show="tabIndex === 0" type="primary" icon="download" @click="handleApplyExportXls('请购单信息')">导出</a-button>
      <a-button v-show="tabIndex === 0" @click="handleUnCreatedClose" type="primary" icon="close">关闭</a-button>
      <!-- <a-upload
        name="file"
        :showUploadList="false"
        :multiple="false"
        :headers="tokenHeader"
        :action="importExcelUrl"
        @change="handleImportExcel"
      >
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload> -->
      <!-- 高级查询区域 -->
      <!-- <j-super-query
        :fieldList="superFieldList"
        ref="superQueryModal"
        @handleSuperQuery="handleSuperQuery"
      ></j-super-query> -->
       <a-dropdown v-if="selectedRowKeys.length > 0 && tabIndex === 1">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDelNotGenerated"><a-icon type="delete" />删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
      <a-dropdown v-if="selectedRowKeysNeedEdit.length > 0 && tabIndex === 2">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDelNeedEdit"><a-icon type="delete" />删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ curSelectedRowKeys.length }}</a
        >项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
        <span style="float:right;">
          <a-popover title="自定义列" trigger="click" placement="leftBottom">
            <template slot="content">
              <a-checkbox-group @change="onColSettingsChange" v-model="settingColumns" :defaultValue="settingColumns">
                <a-row style="width: 400px">
                  <template v-for="(item,index) in defColumns">
                    <template v-if="item.key!=='rowIndex'&& item.dataIndex!=='action'">
                        <a-col :span="12"><a-checkbox :value="item.dataIndex"><j-ellipsis :value="item.title" :length="10"></j-ellipsis></a-checkbox></a-col>
                    </template>
                  </template>
                </a-row>
              </a-checkbox-group>
            </template>
            <a><a-icon type="setting" />设置</a >
          </a-popover>
        </span>
      </div>
      <a-tabs v-model="activeKey" @change="handleChangeTab">
        <a-tab-pane key="unCreated" tab="未生成">
          <!--<a-form layout="inline" @keyup.enter.native="searchQuery">
            <a-row :gutter="2">
              <a-col :xl="8" :lg="11" :md="12" :sm="24">
                <a-form-item label="制单日期">
                  <j-date placeholder="请选择开始日期" class="query-group-cust" v-model="unCreated_startTime_begin"></j-date>
                  <span class="query-group-split-cust"></span>
                  <j-date placeholder="请选择结束日期" class="query-group-cust" v-model="unCreated_startTime_end"></j-date>
                </a-form-item>
              </a-col>
              <a-col :xl="6" :lg="7" :md="8" :sm="24">
                <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
                  <a-button type="primary" @click="searchQueryUnCreated" icon="search">查询</a-button>
                </span>
              </a-col>
            </a-row>
          </a-form>-->
          <a-table
            ref="table"
            size="middle"
            bordered
            :rowKey="
              (record, index) => {
                return record.detailId
              }
            "
            class="j-table-force-nowrap1"
            :scroll="{ x: true }"
            :columns="columns2"
            :dataSource="unCreatedTable.dataSource"
            :pagination="unCreatedTable.ipagination"
            :loading="unCreatedTable.loading"
            :rowSelection="{ selectedRowKeys: selectedRowKeysUncreated, onChange: onSelectChangeUncreated }"
            @change="handleTableChange1"
          >
            <template slot="htmlSlot" slot-scope="text">
              <div v-html="text"></div>
            </template>
            <template slot="imgSlot" slot-scope="text, record">
              <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
              <img
                v-else
                :src="getImgView(text)"
                :preview="record.id"
                height="25px"
                alt=""
                style="max-width: 80px; font-size: 12px; font-style: italic"
              />
            </template>
            <template slot="fileSlot" slot-scope="text">
              <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
              <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
                下载
              </a-button>
            </template>
          </a-table>
        </a-tab-pane>
        <a-tab-pane key="notGenerated" tab="暂存中">
          <!--<a-form layout="inline" @keyup.enter.native="searchQuery">
            <a-row :gutter="2">
              <a-col :xl="8" :lg="11" :md="12" :sm="24">
                <a-form-item label="制单日期">
                  <j-date placeholder="请选择开始日期" class="query-group-cust" v-model="notGenerated_startTime_begin"></j-date>
                  <span class="query-group-split-cust"></span>
                  <j-date placeholder="请选择结束日期" class="query-group-cust" v-model="notGenerated_startTime_end"></j-date>
                </a-form-item>
              </a-col>
              <a-col :xl="6" :lg="7" :md="8" :sm="24">
                <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
                  <a-button type="primary" @click="searchQueryNotGenerated" icon="search">查询</a-button>
                </span>
              </a-col>
            </a-row>
          </a-form>-->
          <a-table
            ref="table"
            size="middle"
            bordered
            :rowKey="
              (record, index) => {
                return record.detailId
              }
            "
            class="j-table-force-nowrap1"
            :scroll="{ x: true }"
            :columns="columns"
            :dataSource="notGeneratedTable.dataSource"
            :pagination="notGeneratedTable.ipagination"
            :loading="notGeneratedTable.loading"
            :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
            @change="handleTableChange2"
          >
            <template slot="htmlSlot" slot-scope="text">
              <div v-html="text"></div>
            </template>
            <template slot="imgSlot" slot-scope="text, record">
              <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
              <img
                v-else
                :src="getImgView(text)"
                :preview="record.id"
                height="25px"
                alt=""
                style="max-width: 80px; font-size: 12px; font-style: italic"
              />
            </template>
            <template slot="fileSlot" slot-scope="text">
              <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
              <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
                下载
              </a-button>
            </template>

            <span slot="action" slot-scope="text, record">
              <a v-if="record.status < 0" @click="handleEdit(record)">编辑</a>
              <a-divider type="vertical"></a-divider>
              <act-apply-btn
                v-show="record.status < 0"
                @success="loadTabData"
                :data-id="record.id"
                :serviceName="serviceName"
                :variables="record"
              ></act-apply-btn>
              <!--<act-historic-detail-btn :data-id="record.id"></act-historic-detail-btn>-->
              <a-divider type="vertical" />
              <a-dropdown>
                <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
                <a-menu slot="overlay">
                  <a-menu-item>
                    <a @click="handleDetail(record)">详情</a>
                  </a-menu-item>
                  <a-menu-item>
                    <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.detailId)">
                      <a>删除</a>
                    </a-popconfirm>
                  </a-menu-item>
                </a-menu>
              </a-dropdown>
            </span>
          </a-table>
        </a-tab-pane>
        <a-tab-pane key="needEdit" tab="需修改">
          <a-table
            ref="needEditTable"
            size="middle"
            bordered
            :rowKey="
              (record, index) => {
                return record.detailId
              }
            "
            class="j-table-force-nowrap1"
            :scroll="{ x: true }"
            :columns="columns"
            :dataSource="needEditTable.dataSource"
            :pagination="needEditTable.ipagination"
            :loading="needEditTable.loading"
            :rowSelection="{ selectedRowKeys: selectedRowKeysNeedEdit, onChange: onSelectChangeNeedEdit }"
            @change="handleTableChange3"
          >
            <template slot="htmlSlot" slot-scope="text">
              <div v-html="text"></div>
            </template>
            <template slot="imgSlot" slot-scope="text, record">
              <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
              <img
                v-else
                :src="getImgView(text)"
                :preview="record.id"
                height="25px"
                alt=""
                style="max-width: 80px; font-size: 12px; font-style: italic"
              />
            </template>
            <template slot="fileSlot" slot-scope="text">
              <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
              <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
                下载
              </a-button>
            </template>

            <span slot="action" slot-scope="text, record">
              <a v-if="record.status < 0" @click="handleEdit(record)">编辑</a>
              <a-divider type="vertical"></a-divider>
              <act-apply-btn
                v-show="record.status < 0"
                @success="loadTabData"
                :data-id="record.id"
                :serviceName="serviceName"
                :variables="record"
              ></act-apply-btn>
              <act-historic-detail-btn :data-id="record.id"></act-historic-detail-btn>
              <a-divider type="vertical" />
              <a-dropdown>
                <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
                <a-menu slot="overlay">
                  <a-menu-item>
                    <a @click="handleDetail(record)">详情</a>
                  </a-menu-item>
                  <a-menu-item>
                    <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.detailId)">
                      <a>删除</a>
                    </a-popconfirm>
                  </a-menu-item>
                </a-menu>
              </a-dropdown>
            </span>
          </a-table>
        </a-tab-pane>
        <a-tab-pane key="approving" tab="审批中">
          <a-table
            ref="approvingTable"
            size="middle"
            bordered
            rowKey="detailId"
            class="j-table-force-nowrap1"
            :scroll="{ x: true }"
            :columns="columns"
            :dataSource="approvingTable.dataSource"
            :pagination="approvingTable.ipagination"
            :loading="approvingTable.loading"
            :rowSelection="{ selectedRowKeys: selectedRowKeysApproving, onChange: onSelectChangeApproving }"
            @change="handleTableChange4"
          >
            <template slot="htmlSlot" slot-scope="text">
              <div v-html="text"></div>
            </template>
            <template slot="imgSlot" slot-scope="text, record">
              <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
              <img
                v-else
                :src="getImgView(text)"
                :preview="record.id"
                height="25px"
                alt=""
                style="max-width: 80px; font-size: 12px; font-style: italic"
              />
            </template>
            <template slot="fileSlot" slot-scope="text">
              <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
              <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
                下载
              </a-button>
            </template>

            <span slot="action" slot-scope="text, record">
              <act-historic-detail-btn :data-id="record.id"></act-historic-detail-btn>
              <a-divider type="vertical" />
              <a-dropdown>
                <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
                <a-menu slot="overlay">
                  <a-menu-item>
                    <a @click="handleDetail(record)">详情</a>
                  </a-menu-item>
                  <a-menu-item>
              <a-popconfirm  v-if="record.actStatus != '撤回'" title="确定取消申请吗?" @confirm="() => handleStop(record)">
               <a href="javascript:;">取消申请</a>
              </a-popconfirm>
                  </a-menu-item>
                </a-menu>
              </a-dropdown>
            </span>
          </a-table>
        </a-tab-pane>
        <a-tab-pane key="approved" tab="已审批">
          <!--<a-form layout="inline" @keyup.enter.native="searchQuery">
            <a-row :gutter="2">
              <a-col :xl="8" :lg="11" :md="12" :sm="24">
                <a-form-item label="制单日期">
                  <j-date placeholder="请选择开始日期" class="query-group-cust" v-model="startTime_begin"></j-date>
                  <span class="query-group-split-cust"></span>
                  <j-date placeholder="请选择结束日期" class="query-group-cust" v-model="startTime_end"></j-date>
                </a-form-item>
              </a-col>
              <a-col :xl="6" :lg="7" :md="8" :sm="24">
                <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
                  <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                </span>
              </a-col>
            </a-row>
          </a-form>-->
          <a-table
            ref="approvedTable"
            size="middle"
            bordered
            rowKey="detailId"
            class="j-table-force-nowrap1"
            :scroll="{ x: true }"
            :columns="columns"
            :dataSource="approvedTable.dataSource"
            :pagination="approvedTable.ipagination"
            :loading="approvedTable.loading"
            :rowSelection="{ selectedRowKeys: selectedRowKeysApproved, onChange: onSelectChangeApproved }"
            @change="handleTableChange5"
          >
            <template slot="htmlSlot" slot-scope="text">
              <div v-html="text"></div>
            </template>
            <template slot="imgSlot" slot-scope="text, record">
              <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
              <img
                v-else
                :src="getImgView(text)"
                :preview="record.id"
                height="25px"
                alt=""
                style="max-width: 80px; font-size: 12px; font-style: italic"
              />
            </template>
            <template slot="fileSlot" slot-scope="text">
              <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
              <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
                下载
              </a-button>
            </template>

            <span slot="action" slot-scope="text, record">
              <act-historic-detail-btn :data-id="record.id"></act-historic-detail-btn>
              <a-divider type="vertical" />
              <a-dropdown>
                <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
                <a-menu slot="overlay">
                  <a-menu-item>
                    <a @click="handleDetail(record)">详情</a>
                  </a-menu-item>
                </a-menu>
              </a-dropdown>
            </span>
          </a-table>
        </a-tab-pane>
      </a-tabs>
    </div>

    <buss-equipment-procurement-plan-modal ref="modalForm" @ok="modalFormOk" />
    <buss-equipment-application-modal ref="applyModal" @ok="" />
  </a-card>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import  BussEquipmentProcurementPlanModal from './modules/BussEquipmentProcurementPlanModal.vue'
import '@/assets/less/TableExpand.less'
import ApplicationsListModal from '@comp/base/modal/ApplicationsListModal'
import { getAction, getFileAccessHttpUrl, deleteAction } from '@api/manage'
import ActApplyBtn from '@views/flowable/components/ActApplyBtn'
import ActCancelBtn from '@views/flowable/components/ActCancelBtn'
import ActHandleBtn from '@views/flowable/components/ActHandleBtn'
import ActHistoricDetailBtn from '@views/flowable/components/ActHistoricDetailBtn'
import moment from 'dayjs'
import { postAction, downFile } from '../../../api/manage'
import { stopProcess } from '@/views/flowable/api/process'
import BussEquipmentApplicationModal from '../equipmentapply/modules/BussEquipmentApplicationModal.vue'

export default {
  name: 'BussEquipmentProcurementPlanList',
  mixins: [JeecgListMixin],
  components: {
    BussEquipmentProcurementPlanModal,
    ApplicationsListModal,
    ActApplyBtn,
    ActCancelBtn,
    ActHandleBtn,
    ActHistoricDetailBtn,
    BussEquipmentApplicationModal,
  },
  data() {
    return {
      description: '设备采购计划单管理页面',
      serviceName: 'equipmentPlanService',
      activeKey: 'unCreated',
      startTime_begin: '',
      startTime_end: '',
      dateFormat: 'YYYY-MM-DD',
      moment,
      tabIndex: 0,
      selectedRowKeysApproving: [],
      selectedRowKeysUncreated: [],
      selectionRowsApproving: [],
      selectionRowsUncreated: [],
      selectedRowKeysApproved: [],
      selectedRowsApproved: [],
      selectedRowKeysNeedEdit: [],
      selectedRowsNeedEdit: [],
      notGenerated_startTime_begin: moment().subtract(7, 'days').format('YYYY-MM-DD'),
      notGenerated_startTime_end: moment().format('YYYY-MM-DD'),
      unCreated_startTime_begin: moment().subtract(7, 'days').format('YYYY-MM-DD'),
      unCreated_startTime_end: moment().format('YYYY-MM-DD'),
      sourceFrom: '13',
      unCreatedTable: {
        loading: false,
        dataSource: [],
        // 表头
        ipagination: {
          current: 1,
          pageSize: 30,
          pageSizeOptions: ['10', '20', '30', '3000', '6000', '9000'],
          showTotal: (total, range) => {
            return range[0] + '-' + range[1] + ' 共' + total + '条'
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0,
        },
      },
      notGeneratedTable: {
        loading: false,
        dataSource: [],
        // 表头
        ipagination: {
          current: 1,
          pageSize: 30,
          pageSizeOptions: ['10', '20', '30', '3000', '6000', '9000'],
          showTotal: (total, range) => {
            return range[0] + '-' + range[1] + ' 共' + total + '条'
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0,
        },
      },
      needEditTable: {
        loading: false,
        dataSource: [],
        // 表头
        ipagination: {
          current: 1,
          pageSize: 30,
          pageSizeOptions: ['10', '20', '30', '3000', '6000', '9000'],
          showTotal: (total, range) => {
            return range[0] + '-' + range[1] + ' 共' + total + '条'
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0,
        },
      },
      approvingTable: {
        loading: false,
        dataSource: [],
        // 表头
        ipagination: {
          current: 1,
          pageSize: 30,
          pageSizeOptions: ['10', '20', '30', '3000', '6000', '9000'],
          showTotal: (total, range) => {
            return range[0] + '-' + range[1] + ' 共' + total + '条'
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0,
        },
      },
      approvedTable: {
        loading: false,
        dataSource: [],
        // 表头
        ipagination: {
          current: 1,
          pageSize: 30,
          pageSizeOptions: ['10', '20', '30', '3000', '6000', '9000'],
          showTotal: (total, range) => {
            return range[0] + '-' + range[1] + ' 共' + total + '条'
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0,
        },
      },
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '设备计划单号',
          align: 'center',
          dataIndex: 'code',
        },
        {
          title: '设备请购单号',
          align: 'center',
          dataIndex: 'applicationCode',
          customRender: (text) => {
            if (!text) return '';
            return text;
          }
        },
        {
          title: '物料编码',
          align: 'center',
          dataIndex: 'materialCode',
        },
        {
          title: '物料名称',
          align: 'center',
          dataIndex: 'materialName',
        },
        {
          title: '规格型号',
          align: 'center',
          dataIndex: 'spec',
        },
        {
          title: '单位',
          align: 'center',
          dataIndex: 'unit',
        },
        {
          title: '采购数量',
          align: 'center',
          dataIndex: 'num',
        },
        {
          title: '供货单位',
          align: 'center',
          dataIndex: 'supplierName',
          customRender: (text) => {
            if (!text) return '';
            return text;
          }
        },
        {
          title: '开始日期',
          align: 'center',
          dataIndex: 'startTime',
          customRender: (text) => {
            if (!text) return '';
            return moment(text).format('YYYY-MM-DD');
          }
        },
        {
          title: '结束日期',
          align: 'center',
          dataIndex: 'endTime',
          customRender: (text) => {
            if (!text) return '';
            return moment(text).format('YYYY-MM-DD');
          }
        },
        {
          title: '提报日期',
          align: 'center',
          dataIndex: 'tjdate',
          customRender: (text) => {
            if (!text) return '';
            return moment(text).format('YYYY-MM-DD');
          }
        },
        {
          title: '到货日期',
          align: 'center',
          dataIndex: 'arrivalDate',
          customRender: (text) => {
            if (!text) return '';
            return moment(text).format('YYYY-MM-DD');
          }
        },
        {
          title: '用途',
          align: 'center',
          dataIndex: 'useDesc',
          customRender: (text) => {
            if (!text) return '';
            return text;
          }
        },
        {
          title: '是否开启',
          align: 'center',
          dataIndex: 'openState_dictText',
        },
        {
          title: '制单人',
          align: 'center',
          dataIndex: 'createUserName',
        },
        {
          title: '制单部门',
          align: 'center',
          dataIndex: 'sysOrgName',
        },
        {
          title: '制单日期',
          align: 'center',
          dataIndex: 'createTime',
          key: 'createTime',
          customRender: (text) => {
            if (!text) return '';
            return moment(text).format('YYYY-MM-DD');
          }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],
      settingColumns: [],
      defColumns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '设备计划单号',
          align: 'center',
          dataIndex: 'code',
        },
        {
          title: '设备请购单号',
          align: 'center',
          dataIndex: 'applicationCode',
          customRender: (text) => {
            if (!text) return '';
            return text;
          }
        },
        {
          title: '物料编码',
          align: 'center',
          dataIndex: 'materialCode',
        },
        {
          title: '物料名称',
          align: 'center',
          dataIndex: 'materialName',
        },
        {
          title: '规格型号',
          align: 'center',
          dataIndex: 'spec',
        },
        {
          title: '单位',
          align: 'center',
          dataIndex: 'unit',
        },
        {
          title: '采购数量',
          align: 'center',
          dataIndex: 'num',
        },
        {
          title: '供货单位',
          align: 'center',
          dataIndex: 'supplierName',
          customRender: (text) => {
            if (!text) return '';
            return text;
          }
        },
        {
          title: '开始日期',
          align: 'center',
          dataIndex: 'startTime',
          customRender: (text) => {
            if (!text) return '';
            return moment(text).format('YYYY-MM-DD');
          }
        },
        {
          title: '结束日期',
          align: 'center',
          dataIndex: 'endTime',
          customRender: (text) => {
            if (!text) return '';
            return moment(text).format('YYYY-MM-DD');
          }
        },
        {
          title: '提报日期',
          align: 'center',
          dataIndex: 'tjdate',
          customRender: (text) => {
            if (!text) return '';
            return moment(text).format('YYYY-MM-DD');
          }
        },
        {
          title: '到货日期',
          align: 'center',
          dataIndex: 'arrivalDate',
          customRender: (text) => {
            if (!text) return '';
            return moment(text).format('YYYY-MM-DD');
          }
        },
        {
          title: '用途',
          align: 'center',
          dataIndex: 'useDesc',
          customRender: (text) => {
            if (!text) return '';
            return text;
          }
        },
        {
          title: '是否开启',
          align: 'center',
          dataIndex: 'openState_dictText',
        },
        {
          title: '制单人',
          align: 'center',
          dataIndex: 'createUserName',
        },
        {
          title: '制单部门',
          align: 'center',
          dataIndex: 'sysOrgName',
        },
        {
          title: '制单日期',
          align: 'center',
          dataIndex: 'createTime',
          key: 'createTime',
          customRender: (text) => {
            if (!text) return '';
            return moment(text).format('YYYY-MM-DD');
          }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],
      columns2: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '设备请购单号',
          align: 'center',
          dataIndex: 'applicationCode',
        },
        {
          title: '物料编码',
          dataIndex: 'materialCode',
        },
        {
          title: '物料名称',
          dataIndex: 'materialName',
        },
        {
          title: '规格型号',
          dataIndex: 'spec',
        },
        {
          title: '单位',
          dataIndex: 'unit',
        },
        {
          title: '请购数量',
          dataIndex: 'applyNum',
        },
        {
          title: '用途',
          dataIndex: 'useDesc',
        },
        {
          title: '到货日期',
          dataIndex: 'arrivalDate',
          width: 100,
          customRender: (text) => {
            if (!text) return '';
            return moment(text).format('YYYY-MM-DD');
          }
        },
        {
          title: '是否开启',
          dataIndex: 'openState_dictText',
        },
        {
          title: '申请人',
          dataIndex: 'applyUserName',
          width: 100,
        },
        {
          title: '申请部门',
          dataIndex: 'sysOrgCodeName',
          width: 150,
        },
        {
          title: '申请日期',
          dataIndex: 'tjdate',
          width: 100,
          customRender: (text) => {
            if (!text) return '';
            return moment(text).format('YYYY-MM-DD');
          }
        },
      ],
      url: {
        list: '/plan/bussMaterialProcurementPlan/list',
        delete: '/plan/bussMaterialProcurementPlan/delete',
        deleteBatch: '/plan/bussMaterialProcurementPlan/deleteBatch',
        deleteDetail: '/plan/bussMaterialProcurementPlan/deleteDetail',
        exportXlsUrl: '/plan/bussMaterialProcurementPlan/exportXls',
        importExcelUrl: 'plan/bussMaterialProcurementPlan/importExcel',
        openDetailUrl: '/plan/bussMaterialProcurementPlan/openPlanBillDetail',
        closeDetailUrl: '/plan/bussMaterialProcurementPlan/closePlanBillDetail',
        exportApplyXlsUrl: '/procurement/exportXls',
        closeApplyDetailUrl: '/procurement/closeApplicationBillDetail',
      },
      dictOptions: {},
      superFieldList: [],
    }
  },
  created() {
    this.sourceFrom = '13'
    this.getSuperFieldList()
    this.startTime_begin = moment().subtract(7, 'days').format(this.dateFormat)
    this.startTime_end = moment().format(this.dateFormat)
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
    curSelectedRowKeys: function () {
      if (this.tabIndex === 0) {
        return this.selectedRowKeysUncreated
      } else if (this.tabIndex === 1) {
        return this.selectedRowKeys
      } else if (this.tabIndex === 2) {
        return this.selectedRowKeysNeedEdit
      } else if (this.tabIndex === 3) {
        return this.selectedRowKeysApproving
      } else if (this.tabIndex === 4) {
        return this.selectedRowKeysApproved
      }
    },
  },
  methods: {
    initDictConfig() {},
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'string', value: 'code', text: '单据编号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'applicationId', text: '请购单ID', dictCode: '' })
      fieldList.push({ type: 'date', value: 'startTime', text: '开始日期' })
      fieldList.push({ type: 'date', value: 'endTime', text: '结束日期' })
      fieldList.push({ type: 'date', value: 'submissionDate', text: '提报日期' })
      fieldList.push({ type: 'string', value: 'status', text: '是否开启', dictCode: '' })
      this.superFieldList = fieldList
    },
    handleChangeTab() {
      switch (this.activeKey) {
        case 'unCreated':
          this.loadUnCreatedData()
          break
        case 'notGenerated':
          this.loadNotGeneratedData()
          break
        case 'needEdit':
          this.loadNeedEditData()
          break
        case 'approving':
          this.loadApprovingData()
          break
        case 'approved':
          this.loadApprovedData()
          break
        default:
          break
      }
    },
    loadUnCreatedData() {
      //未生成 找请购单审批完成的
      this.tabIndex = 0
      this.queryParam.status = 999
      this.queryParam.openState = 'Y'
      this.queryParam.sourceFrom = '13'
      this.queryParam.pageNo = this.unCreatedTable.ipagination.current;
      this.queryParam.pageSize = this.unCreatedTable.ipagination.pageSize;
      this.unCreatedTable.loading = true
      let para = {
        ...this.queryParam,
        createTimeBg: this.unCreated_startTime_begin ? this.unCreated_startTime_begin + ' 00:00:00' : '',
        createTimeEd: this.unCreated_startTime_end ? this.unCreated_startTime_end + ' 23:59:59' : '',
      }
      let myurl = '/procurement/list'
      getAction(myurl, para)
        .then((res) => {
          if (res.success) {
            this.unCreatedTable.dataSource = res.result.records || res.result
            if (res.result.total) {
              this.unCreatedTable.ipagination.total = res.result.total
            } else {
              this.unCreatedTable.ipagination.total = 0
            }
          } else {
            this.$message.warning(res.message)
          }
        })
        .finally(() => {
          this.unCreatedTable.loading = false
        })
    },
    loadNotGeneratedData() {
      //暂存中，status=-2
      this.tabIndex = 1
      this.queryParam.status = -2
      this.queryParam.openState = ''
      this.queryParam.sourceFrom = '13'
      this.queryParam.pageNo = this.notGeneratedTable.ipagination.current;
      this.queryParam.pageSize = this.notGeneratedTable.ipagination.pageSize;
      this.notGeneratedTable.loading = true
      let para = {
        ...this.queryParam,
        createTimeBg: this.notGenerated_startTime_begin ? this.notGenerated_startTime_begin + ' 00:00:00' : '',
        createTimeEd: this.notGenerated_startTime_end ? this.notGenerated_startTime_end + ' 23:59:59' : '',
      }
      getAction(this.url.list, para)
        .then((res) => {
          if (res.success) {
            this.notGeneratedTable.dataSource = res.result.records || res.result
            if (res.result.total) {
              this.notGeneratedTable.ipagination.total = res.result.total
            } else {
              this.notGeneratedTable.ipagination.total = 0
            }
          } else {
            this.$message.warning(res.message)
          }
        })
        .finally(() => {
          this.notGeneratedTable.loading = false
        })
    },
    //需修改
    loadNeedEditData() {
      //需修改单据，status=-1
      this.tabIndex = 2
      this.queryParam.status = -1
      this.queryParam.openState = ''
      this.queryParam.sourceFrom = '13'
      this.queryParam.pageNo = this.needEditTable.ipagination.current;
      this.queryParam.pageSize = this.needEditTable.ipagination.pageSize;
      this.needEditTable.loading = true
      getAction(this.url.list, this.queryParam)
        .then((res) => {
          if (res.success) {
            this.needEditTable.dataSource = res.result.records || res.result
            if (res.result.total) {
              this.needEditTable.ipagination.total = res.result.total
            } else {
              this.needEditTable.ipagination.total = 0
            }
          } else {
            this.$message.warning(res.message)
          }
        })
        .finally(() => {
          this.needEditTable.loading = false
        })
    },
    //审判中
    loadApprovingData() {
      //审核中单据，status=0
      this.tabIndex = 3
      this.queryParam.status = 0
      this.queryParam.openState = ''
      this.queryParam.sourceFrom = '13'
      this.queryParam.pageNo = this.approvingTable.ipagination.current;
      this.queryParam.pageSize = this.approvingTable.ipagination.pageSize;
      this.approvingTable.loading = true
      getAction(this.url.list, this.queryParam)
        .then((res) => {
          if (res.success) {
            this.approvingTable.dataSource = res.result.records || res.result
            if (res.result.total) {
              this.approvingTable.ipagination.total = res.result.total
            } else {
              this.approvingTable.ipagination.total = 0
            }
          } else {
            this.$message.warning(res.message)
          }
        })
        .finally(() => {
          this.approvingTable.loading = false
        })
    },
    //已审批
    loadApprovedData() {
      //已审核单据，status=999
      this.queryParam.openState = ''
      this.queryParam.status = 999
      this.queryParam.sourceFrom = '13'
      this.queryParam.pageNo = this.approvedTable.ipagination.current;
      this.queryParam.pageSize = this.approvedTable.ipagination.pageSize;
      this.tabIndex = 4
      let para = {
        ...this.queryParam,
        createTimeBg: this.startTime_begin ? this.startTime_begin + ' 00:00:00' : '',
        createTimeEd: this.startTime_end ? this.startTime_end + ' 23:59:59' : '',
      }
      this.approvedTable.loading = true
      getAction(this.url.list, para)
        .then((res) => {
          if (res.success) {
            this.approvedTable.dataSource = res.result.records || res.result
            if (res.result.total) {
              this.approvedTable.ipagination.total = res.result.total
            } else {
              this.approvedTable.ipagination.total = 0
            }
          } else {
            this.$message.warning(res.message)
          }
        })
        .finally(() => {
          this.approvedTable.loading = false
        })
    },
    async loadData() {
      //分别根据单据状态查询结果并将其放在
      this.queryParam = this.getQueryParams()
      this.loadUnCreatedData()
    },
    loadTabData() {
      const refreshMethod = this.getCurrentTabLoadMethod()
      refreshMethod()
    },
    onSelectChangeUncreated(selectedRowKeys, selectionRows) {
      this.selectedRowKeysUncreated = selectedRowKeys
      this.selectionRowsUncreated = selectionRows
    },
    onSelectChangeApproving(selectedRowKeys, selectionRows) {
      this.selectedRowKeysApproving = selectedRowKeys
      this.selectionRowsApproving = selectionRows
    },
    onSelectChangeApproved(selectedRowKeys, selectionRows) {
      this.selectedRowKeysApproved = selectedRowKeys
      this.selectedRowsApproved = selectionRows
    },
    onSelectChangeNeedEdit(selectedRowKeys, selectionRows) {
      this.selectedRowKeysNeedEdit = selectedRowKeys
      this.selectedRowsNeedEdit = selectionRows
    },
    handleAdd: function () {
      if (this.selectionRowsUncreated.length <= 0) {
        this.$message.warning('请先选择设备请购单！')
        return
      }
      // let ids = this.selectionRowsUncreated.map(row => row.id);
      // this.$store.dispatch('saveSelectedIds', ids);
      this.$store.dispatch('saveMaterialApplications', this.selectionRowsUncreated);
      this.$refs.modalForm.add()
      this.$refs.modalForm.title = '新增'
      this.$refs.modalForm.disableSubmit = false
    },
    getCurrentTabLoadMethod() {
      switch (this.activeKey) {
        case 'unCreated':
          return this.loadUnCreatedData;
        case 'notGenerated':
          return this.loadNotGeneratedData;
        case 'needEdit':
          return this.loadNeedEditData;
        case 'approving':
          return this.loadApprovingData;
        case 'approved':
          return this.loadApprovedData;
        default:
          return this.loadData;
      }
    },

    handleDelete: function (detailId) {
      if (!this.url.deleteDetail) {
        this.$message.error('请设置url.delete属性!')
        return
      }
      let that = this
      deleteAction(that.url.deleteDetail, { detailId: detailId }).then((res) => {
        if (res.success) {
          //重新计算分页问题
          //that.reCalculatePage(1)
          const refreshMethod = that.getCurrentTabLoadMethod()
          refreshMethod() // 执行当前Tab的刷新
          that.$message.success(res.message)
          that.onClearSelected()
        } else {
          that.$message.warning(res.message)
        }
      })
    },
    batchDelNotGenerated: function () {
      if (!this.url.deleteBatch) {
        this.$message.error('请设置url.deleteBatch属性!')
        return
      }
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('请选择一条记录！')
        return
      } else {
        let ids = ''
        for (let a = 0; a < this.selectedRowKeys.length; a++) {
          ids += this.selectedRowKeys[a] + ','
        }
        let that = this
        this.$confirm({
          title: '确认删除',
          content: '是否删除选中数据?',
          onOk: function () {
            that.notGeneratedTable.loading = true
            deleteAction(that.url.deleteBatch, { ids: ids })
              .then((res) => {
                if (res.success) {
                  //重新计算分页问题
                  //that.reCalculatePage(that.selectedRowKeys.length)
                  that.$message.success(res.message)
                  /*that.loadNotGeneratedData()
                  that.onClearSelected()*/
                  const refreshMethod = that.getCurrentTabLoadMethod()
                  refreshMethod() // 执行当前Tab的刷新
                  that.onClearSelected()
                } else {
                  that.$message.warning(res.message)
                }
              })
              .finally(() => {
                that.notGeneratedTable.loading = false
              })
          },
        })
      }
    },
    batchDelNeedEdit: function () {
      if (!this.url.deleteBatch) {
        this.$message.error('请设置url.deleteBatch属性!')
        return
      }
      if (this.selectedRowKeysNeedEdit.length <= 0) {
        this.$message.warning('请选择一条记录！')
        return
      } else {
        let ids = ''
        for (let a = 0; a < this.selectedRowKeysNeedEdit.length; a++) {
          ids += this.selectedRowKeysNeedEdit[a] + ','
        }
        let that = this
        this.$confirm({
          title: '确认删除',
          content: '是否删除选中数据?',
          onOk: function () {
            that.needEditTable.loading = true
            deleteAction(that.url.deleteBatch, { ids: ids })
              .then((res) => {
                if (res.success) {
                  //重新计算分页问题
                  //that.reCalculatePage(that.selectedRowKeysNeedEdit.length)
                  that.$message.success(res.message)
                  /*that.loadNotGeneratedData()
                  that.onClearSelected()*/
                  const refreshMethod = that.getCurrentTabLoadMethod()
                  refreshMethod() // 执行当前Tab的刷新
                  that.onClearSelected()
                } else {
                  that.$message.warning(res.message)
                }
              })
              .finally(() => {
                that.needEditTable.loading = false
              })
          },
        })
      }
    },
    searchQuery() {
      this.loadApprovedData()
    },
    searchReset() {
      this.startTime_begin = ''
      this.startTime_end = ''
      this.loadApprovedData()
    },
    searchQueryNotGenerated() {
      this.loadNotGeneratedData()
    },
    searchResetNotGenerated() {
      this.notGenerated_startTime_begin = ''
      this.notGenerated_startTime_end = ''
      this.loadNotGeneratedData()
    },
    searchQueryUnCreated() {
      this.loadUnCreatedData()
    },
    searchResetUnCreated() {
      this.unCreated_startTime_begin = ''
      this.unCreated_startTime_end = ''
      this.loadUnCreatedData()
    },
    handleOpen() {
      if (this.selectedRowKeysApproved.length <= 0 || this.selectedRowKeysApproved.length > 1) {
        this.$message.warning('请选择一条记录！')
        return
      } else {
        let detailId = this.selectedRowKeysApproved[0].toString()
        let that = this
        this.$confirm({
          title: '提示',
          content: '确认开启此采购计划单?',
          onOk: function () {
            postAction(that.url.openDetailUrl, detailId).then((res) => {
              if (res.success) {
                //重新计算分页问题
                //that.reCalculatePage(that.selectedRowKeysApproved.length)
                that.$message.success(res.message)
                const refreshMethod = that.getCurrentTabLoadMethod()
                refreshMethod()
                that.onClearSelected()
              } else {
                that.$message.warning(res.message)
              }
            })
          },
        })
      }
    },
    handleClose() {
      if (this.selectedRowKeysApproved.length <= 0 || this.selectedRowKeysApproved.length > 1) {
        this.$message.warning('请选择一条记录！')
        return
      } else {
        let detailId = this.selectedRowKeysApproved[0].toString()
        let that = this
        this.$confirm({
          title: '提示',
          content: '确认关闭此材料计划单?',
          onOk: function () {
            postAction(that.url.closeDetailUrl, detailId).then((res) => {
              if (res.success) {
                //重新计算分页问题
                //that.reCalculatePage(that.selectedRowKeysApproved.length)
                that.$message.success(res.message)
                const refreshMethod = that.getCurrentTabLoadMethod()
                refreshMethod()
                that.onClearSelected()
              } else {
                that.$message.warning(res.message)
              }
            })
          },
        })
      }
    },
    modalFormOk() {
      //刷新后 选中的记录清除
      //this.$store.dispatch('saveMaterialApplicationDetailList', [])
      this.$store.dispatch('saveSelectedIds', [])
      // 新增/修改 成功时，重载列表
      // this.loadNotGeneratedData()
      this.handleChangeTab()
      //清空列表选中
      this.onClearSelected()
    },
    handleUnCreatedClose() {
      if (this.selectedRowKeysUncreated.length <= 0 || this.selectedRowKeysUncreated.length > 1) {
        this.$message.warning('请选择一条记录！')
        return
      } else {
        let id = this.selectedRowKeysUncreated[0].toString()
        let that = this
        this.$confirm({
          title: '提示',
          content: '确认关闭当前物料?',
          onOk: function () {
            postAction(that.url.closeApplyDetailUrl, id).then((res) => {
              if (res.success) {
                //重新计算分页问题
                //that.reCalculatePage(that.selectedRowKeysUncreated.length)
                that.$message.success(res.message)
                that.loadUnCreatedData()
                that.onClearSelected()
              } else {
                that.$message.warning(res.message)
              }
            })
          },
        })
      }
    },
    handleApplyExportXls(fileName) {
      if (!fileName || typeof fileName != "string") {
        fileName = "导出文件"
      }
      let param = this.getQueryParams();
      param['exportEntryFlag'] = 1 //新增外部入口标识
      param['pageNo'] = this.unCreatedTable.ipagination.current;
      param['pageSize'] = this.unCreatedTable.ipagination.pageSize;
      param['createTimeBg'] = this.unCreated_startTime_begin ? this.unCreated_startTime_begin + ' 00:00:00' : ''
      param['createTimeEd'] = this.unCreated_startTime_end ? this.unCreated_startTime_end + ' 23:59:59' : ''
      if (this.selectedRowKeysUncreated && this.selectedRowKeysUncreated.length > 0) {
        param['selections'] = this.selectedRowKeysUncreated.join(",")
      }
      console.log("导出参数", param)
      downFile(this.url.exportApplyXlsUrl, param).then((data) => {
        if (!data) {
          this.$message.warning("文件下载失败")
          return
        }
        if (typeof window.navigator.msSaveBlob !== 'undefined') {
          window.navigator.msSaveBlob(new Blob([data], {type: 'application/vnd.ms-excel'}), fileName + '.xls')
        } else {
          let url = window.URL.createObjectURL(new Blob([data], {type: 'application/vnd.ms-excel'}))
          let link = document.createElement('a')
          link.style.display = 'none'
          link.href = url
          link.setAttribute('download', fileName + '.xls')
          document.body.appendChild(link)
          link.click()
          document.body.removeChild(link); //下载完成移除元素
          window.URL.revokeObjectURL(url); //释放掉blob对象
        }
      })
    },
    onClearSelected() {
      this.selectedRowKeysUncreated = [];
      this.selectionRowsUncreated = [];
      this.selectedRowKeys = [];
      this.selectionRows = [];
      this.selectedRowKeysNeedEdit = [];
      this.selectedRowsNeedEdit = [];
      this.selectedRowKeysApproving = [];
      this.selectionRowsApproving = [];
      this.selectedRowKeysApproved = [];
      this.selectedRowsApproved = [];
    },
    handleStop(row) {
      const params = {
        instanceId: row.processInstanceId,
      }
      stopProcess(params).then((res) => {
        this.$message.success(res.message)
        const refreshMethod = this.getCurrentTabLoadMethod()
        refreshMethod()
        this.onClearSelected()
      })
    },
    handlePlanExportXls(fileName) {
      if (!fileName || typeof fileName != "string") {
        fileName = "导出文件"
      }
      let param = this.getQueryParams();
      if (this.tabIndex === 1) {
        param['pageNo'] = this.notGeneratedTable.ipagination.current;
        param['pageSize'] = this.notGeneratedTable.ipagination.pageSize;
        param['createTimeBg'] = this.notGenerated_startTime_begin ? this.notGenerated_startTime_begin + ' 00:00:00' : ''
        param['createTimeEd'] = this.notGenerated_startTime_end ? this.notGenerated_startTime_end + ' 23:59:59' : ''
        if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
          param['selections'] = this.selectedRowKeys.join(",")
        }
      }
      if (this.tabIndex === 2) {
        param['pageNo'] = this.needEditTable.ipagination.current;
        param['pageSize'] = this.needEditTable.ipagination.pageSize;
        if (this.selectedRowKeysNeedEdit && this.selectedRowKeysNeedEdit.length > 0) {
          param['selections'] = this.selectedRowKeysNeedEdit.join(",")
        }
      }
      if (this.tabIndex === 3) {
        param['pageNo'] = this.approvingTable.ipagination.current;
        param['pageSize'] = this.approvingTable.ipagination.pageSize;
        if (this.selectedRowKeysApproving && this.selectedRowKeysApproving.length > 0) {
          param['selections'] = this.selectedRowKeysApproving.join(",")
        }
      }
      if (this.tabIndex === 4) {
        param['pageNo'] = this.approvedTable.ipagination.current;
        param['pageSize'] = this.approvedTable.ipagination.pageSize;
        param['createTimeBg'] = this.startTime_begin ? this.startTime_begin + ' 00:00:00' : ''
        param['createTimeEd'] = this.startTime_end ? this.startTime_end + ' 23:59:59' : ''
        if (this.selectedRowKeysApproved && this.selectedRowKeysApproved.length > 0) {
          param['selections'] = this.selectedRowKeysApproved.join(",")
        }
      }
      console.log("导出参数", param)
      downFile(this.url.exportXlsUrl, param).then((data) => {
        if (!data) {
          this.$message.warning("文件下载失败")
          return
        }
        if (typeof window.navigator.msSaveBlob !== 'undefined') {
          window.navigator.msSaveBlob(new Blob([data], {type: 'application/vnd.ms-excel'}), fileName + '.xls')
        } else {
          let url = window.URL.createObjectURL(new Blob([data], {type: 'application/vnd.ms-excel'}))
          let link = document.createElement('a')
          link.style.display = 'none'
          link.href = url
          link.setAttribute('download', fileName + '.xls')
          document.body.appendChild(link)
          link.click()
          document.body.removeChild(link); //下载完成移除元素
          window.URL.revokeObjectURL(url); //释放掉blob对象
        }
      })
    },
    reviewView() {
      if (this.selectedRowKeysUncreated.length <= 0 || this.selectedRowKeysUncreated.length > 1) {
        this.$message.warning('请选择一条记录！')
        return
      } else {
        this.$refs.applyModal.edit(this.selectionRowsUncreated[0]);
        this.$refs.applyModal.title = "详情";
        this.$refs.applyModal.disableSubmit = true;
      }
    },
    handleTableChange1(pagination, filters, sorter) {
      //分页、排序、筛选变化时触发
      //TODO 筛选
      console.log(pagination)
      /*if (Object.keys(sorter).length > 0) {
        this.isorter.column = sorter.field;
        this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
      }*/
      this.unCreatedTable.ipagination = pagination;
      this.loadUnCreatedData();
    },
    handleTableChange2(pagination, filters, sorter) {
      //分页、排序、筛选变化时触发
      //TODO 筛选
      console.log(pagination)
      /*if (Object.keys(sorter).length > 0) {
        this.needEditTable.isorter.column = sorter.field;
        this.needEditTable.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
      }*/
      this.notGeneratedTable.ipagination = pagination;
      this.loadNotGeneratedData();
    },
    handleTableChange3(pagination, filters, sorter) {
      //分页、排序、筛选变化时触发
      //TODO 筛选
      console.log(pagination)
      /*if (Object.keys(sorter).length > 0) {
        this.approvingTable.isorter.column = sorter.field;
        this.approvingTable.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
      }*/
      this.needEditTable.ipagination = pagination;
      this.loadNeedEditData();
    },
    handleTableChange4(pagination, filters, sorter) {
      //分页、排序、筛选变化时触发
      //TODO 筛选
      console.log(pagination)
      /*if (Object.keys(sorter).length > 0) {
        this.approvedTable.isorter.column = sorter.field;
        this.approvedTable.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
      }*/
      this.approvingTable.ipagination = pagination;
      this.loadApprovingData();
    },
    handleTableChange5(pagination, filters, sorter) {
      //分页、排序、筛选变化时触发
      //TODO 筛选
      console.log(pagination)
      /*if (Object.keys(sorter).length > 0) {
        this.approvedTable.isorter.column = sorter.field;
        this.approvedTable.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
      }*/
      this.approvedTable.ipagination = pagination;
      this.loadApprovedData();
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
